local sk__sheji = fk.CreateSkill {

  name = "sk__sheji",

  tags = {},

}



sk__sheji:addEffect("viewas", {
  name = "sk__sheji",
  anim_type = "offensive",
  pattern = "slash",
  prompt = "#sk__sheji",
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).type == Card.TypeEquip
  end,
  view_as = function(self, player, cards)
    if #cards ~= 1 then return nil end
    local card = Fk:cloneCard("slash")
    card:addSubcard(cards[1])
    card.skillName = sk__sheji.name
    return card
  end,
})

sk__sheji:addEffect(fk.Damage, {
  name = "#sk__sheji_trigger",
  mute = true,
  --sk__sheji,
  can_trigger = function(self, event, target, player, data)
    return target and target ~= player and player:hasSkill(sk__sheji.name) and
        #target:getEquipments(Card.SubtypeWeapon) > 0 and
        not player:isNude()
  end,
  on_cost = function(self, event, target, player, data)
    local card = player.room:askForDiscard(player, 1, 1, true, "sk__sheji", true, ".", "#sk__sheji-invoke::" .. target
    .id, true)
    if #card > 0 then
      event:setCostData(self, card)
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke("sk__sheji")
    room:notifySkillInvoked(player, "sk__sheji", "control")
    room:throwCard(event:getCostData(self), sk__sheji.name, player, player)
    local cards = target:getEquipments(Card.SubtypeWeapon)
    if player.dead or #cards == 0 then return end
    room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonPrey, "sk__sheji", nil, true, player)
  end,
})
sk__sheji:addEffect(fk.TargetSpecified, {
  can_refresh = function(self, event, target, player, data)
    return target == player and table.contains(data.card.skillNames, "sk__sheji")
  end,
  on_refresh = function(self, event, target, player, data)
    data.fixedResponseTimes = data.fixedResponseTimes or {}
    data.fixedResponseTimes["jink"] = 2
  end,
})

sk__sheji:addEffect("targetmod", {
  name = "#sk__sheji_targetmod",
  bypass_distances = function(self, player, skill, card)
    return skill.trueName == "slash_skill" and table.contains(card.skillNames, "sk__sheji")
  end,
})

return sk__sheji
